package com.banzhi.shop.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.banzhi.shop.R;
import com.banzhi.shop.adapter.MyCollegeAdapter;
import com.banzhi.shop.base.BaseActivity;
import com.banzhi.shop.fragment.PartnerProfit_DaifaFragment;
import com.banzhi.shop.fragment.PartnerProfit_YifaFragment;
import com.banzhi.shop.fragment.Shouyi_DaifaFragment;
import com.banzhi.shop.fragment.Shouyi_YifaFragment;
import com.banzhi.shop.utils.TabLayoutUtil;
import com.banzhi.shop.utils.Translucent;
import com.banzhi.shop.view.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;
//合伙人收益
public class PartnerShouYiActivity extends BaseActivity implements View.OnClickListener {

    private ImageView mIvBackProfit;
    private TabLayout mTabs;
    private NoScrollViewPager mVp;

    private List<String> mTitle = new ArrayList<String>();
    private List<Fragment> mFragment = new ArrayList<Fragment>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_partner_shou_yi);
        Translucent.setTranslucent(this);
        initView();
        initListener();

        MyCollegeAdapter myShopAdaper = new MyCollegeAdapter(getSupportFragmentManager(), mTitle, mFragment);
        mVp.setAdapter(myShopAdaper);
        //为TabLayout设置ViewPager
        mTabs.setupWithViewPager(mVp);
        //使用ViewPager的适配器
        mTabs.setTabsFromPagerAdapter(myShopAdaper);
        //定义tablayout下划线的长度
        mTabs.post(new Runnable() {
            @Override
            public void run() {
                TabLayoutUtil.setIndicator(mTabs, 30, 30);
            }
        });
    }

    private void initView() {
        mIvBackProfit = (ImageView) findViewById(R.id.iv_back_profit);
        mTabs = (TabLayout) findViewById(R.id.tabs);
        mVp = (NoScrollViewPager) findViewById(R.id.vp);

        mTitle.add("待发放");
        mTitle.add("已发放");
        mFragment.add(new PartnerProfit_DaifaFragment());
        mFragment.add(new PartnerProfit_YifaFragment());

    }

    private void initListener() {
        mIvBackProfit.setOnClickListener(this);


    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back_profit:
                finish();
                break;
        }

    }
}
